home *** CD-ROM | disk | FTP | other *** search
- #include <stdlib.h>
- #include <string.h>
- #include <sys/stat.h>
- #include "misc.h"
- #include "../paths.h"
-
- static char *lang = strdup("eng");
- static HELP_FILE *first = NULL;
-
- /*
- Record the language to use for help files
- */
- void help_setlang (const char *_lang)
- {
- free (lang);
- lang = strdup(_lang);
- }
-
- /*
- Record the spec of a config file that is maintain (or used) by linuxconf
- */
- PUBLIC HELP_FILE::HELP_FILE(
- const char *_subdir,
- const char *_fname)
- {
- /* #Specification: help file / path
- All help file of linuxconf are under the same directory
- USR_LIB_CONF. Each subject (netconf, userconf, etc...) has
- its own subdirectory under this directory. In these
- subdirectories, we have file ending with the extension help.
- */
- subdir = _subdir;
- fname = _fname;
- path = NULL;
- next = first;
- first = this;
- }
-
- /*
- Return the path of the configuration file
- */
- PUBLIC const char *HELP_FILE::getpath()
- {
- if (path == NULL && fname != NULL){
- char buf[200];
- sprintf (buf,"%s/help.%s/%s/%s",HELP_BASEPATH,lang,subdir,fname);
- path = strdup (buf);
- }
- return path;
- }
- /*
- Check if all the help file of the application are there.
- This is a runtime check even if it is only requiered for testing
- the software.
- */
- void helpf_checkall()
- {
- HELP_FILE *f = first;
- while (f != NULL){
- const char *path = f->getpath();
- if (path != NULL){
- struct stat st;
- printf ("%s%s\n"
- ,stat(path,&st)!=-1 ? "\t" : "***\t"
- ,path);
- }
- f = f->next;
- }
- }
-
- HELP_FILE help_nil (NULL,NULL);
-